package com.itheima.arraylistdemo;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * 操作类：食品系统
 */
public class FoodSystem {
    private ArrayList<Food> menu = new ArrayList<>();
    Scanner sc = new Scanner(System.in);

    //定义一个方法实现欢迎登录界面
    public void start(){
        while(true){System.out.println("=========欢迎进入商家后台管理系统系统=========");
        System.out.println("1.上架菜品");
        System.out.println("2.浏览菜品");
        System.out.println("3.退出系统");
        System.out.println("请您选择操作命令:");
        String command = sc.next();
        switch (command) {
            case "1":
                addFood();//上架菜品
                break;
            case "2": //浏览菜品
                showFood();
                break;
            case "3":
                System.out.println("谢谢，欢迎下次再来~~");
                return;
            default:
                System.out.println("您输入的命令有误，请重新输入！");
        }
        }
    }
//浏览菜品信息
    private void showFood() {
        //如果还没有添加商品 提示
        if(menu.size() == 0){
            System.out.println("当前没有菜品，请先上架菜品！");
        }

        //遍历集合 把菜品的信息展示出来
        for (int i = 0; i < menu.size(); i++) {
            Food foods = menu.get(i);
            System.out.println("====菜品展示====");
            System.out.println("菜品名称：" + foods.getName());
            System.out.println("菜品价格：" + foods.getPrice());
            System.out.println("菜品数量：" + foods.getCount());
            System.out.println("菜品信息：" + foods.getInfo());
            System.out.println("------------------------");
        }

    }
//添加菜品信息
    private void addFood() {
        Food foods = new Food();
        System.out.println("请输入上架的菜品名称：");
        String name = sc.next();
        foods.setName(name);
        System.out.println("请输入上架的菜品价格：");
        double price = sc.nextDouble();
        foods.setPrice(price);
        System.out.println("请输入上架的菜品数量：");
        int count = sc.nextInt();
        foods.setCount(count);
        System.out.println("请输入上架的菜品信息：");
        String info = sc.next();
        foods.setInfo(info);
        //把foods添加到集合中
        menu.add(foods);
        System.out.println("恭喜您，上架成功~");

    }


}